<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="shiro" uri="/WEB-INF/tlds/shiro.tld"%>

<%@include file="/WEB-INF/views/include/inc.jsp"%>
<!DOCTYPE html>
<html>
<head>
<%@include file="/WEB-INF/views/include/head.jsp"%>
<!-- jqgrid-->
<link
	href="<%=contextPath%>/assets/hplus/css/plugins/jqgrid/ui.jqgridffe4.css?0820"
	rel="stylesheet">
<link href="<%=contextPath%>/assets/contextmenu/context.standalone.css"
	rel="stylesheet">
<style type="text/css">
.ui-jqgrid .ui-pg-selbox, .ui-jqgrid .ui-jqgrid-toppager .ui-pg-selbox {
	padding: 0 0 3px 3px;
}
</style>
</head>
<body class="gray-bg">
	<div class="animated">
		<div class="row">
			<div class="col-sm-12">
				<div class="tabs-container">
					<ul class="nav nav-tabs">
						<li class="active"><a data-toggle="tab" href="#tab-1"
							aria-expanded="true">系统操作</a></li>
						<li class=""><a data-toggle="tab" href="#tab-2"
							aria-expanded="false">系统异常</a></li>
					</ul>
					<div class="tab-content">
						<div id="tab-1" class="tab-pane active">
							<div id="panel-body-1" class="panel-body">
								<div class="jqGrid_wrapper">
									<table id="table_list_1"></table>
									<div id="pager_list_1"></div>
								</div>
							</div>
						</div>
						<div id="tab-2" class="tab-pane">
							<div id="panel-body-2" class="panel-body">
								<div class="jqGrid_wrapper">
									<table id="table_list_2"></table>
									<div id="pager_list_2"></div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>

	</div>
	<!-- 全局js -->
	<%@include file="/WEB-INF/views/include/foot.jsp"%>
	<!-- Peity -->
	<script
		src="<%=contextPath%>/assets/hplus/js/plugins/peity/jquery.peity.min.js"></script>

	<!-- jqGrid -->
	<script
		src="<%=contextPath%>/assets/hplus/js/plugins/jqgrid/i18n/grid.locale-cnffe4.js?0820"></script>
	<script
		src="<%=contextPath%>/assets/hplus/js/plugins/jqgrid/jquery.jqGrid.minffe4.js?0820"></script>

	<!-- 自定义js -->
	<script src="<%=contextPath%>/assets/contextmenu/context.js"></script>

	<!-- Page-Level Scripts -->
	<script>
		$(document).ready(function() {
			$.jgrid.defaults.styleUI = "Bootstrap";
			//初始化右键菜单
			context.init({preventDoubleContext: false});
			$("#table_list_1").jqGrid({
				url: '<%=contextPath%>/sys/log/listData',
				data : {},
				datatype : "json",
				autowidth : true,
				shrinkToFit : true,
				mtype : "post",
				rowNum : 20,
				rowList : [ 10, 20, 30 ],
				colNames : ["id", "描述","操作人","操作时间","请求IP"],
				colModel : [{
					name : "id",
					index : "id",
					hidden:true
				},  {
					name : "description",
					index : "description",
					width : 50
				},  {
					name : "operatorName",
					index : "operator_name",
					width : 50
				},  {
					name : "createDate",
					index : "create_date",
					width : 50,
					formatter:"date",
					formatoptions: {srcformat:'Y-m-d H:i:s',newformat:'Y-m-d H:i:s'}
				},  {
					name : "requestIp",
					index : "request_ip",
					width : 50
				}],
				pager : "#pager_list_1",
				viewrecords : true,
				height : $(window).height() - 160,
				hidegrid : false,
				refresh : true
			}).navGrid('#pager_list_1',{edit:false,add:false,del:false,search:true,refresh:true});
		
			
			<shiro:hasAnyPermission name="sys:log:view1"> 
			//对表格设置右键菜单
			context.attach('#table_list_1', [
			<shiro:hasPermission name="sys:log:view1">  
          		{
          			text: '查看详情',
          			action:function(){
          				var selectedIds = $("#table_list_1").jqGrid("getGridParam", "selrow");
       				    var rowData = $("#table_list_1").jqGrid("getRowData",selectedIds);
       				    var isConfirm = true;
       				    parent.layer.open({
	 			        	title:'日志详情',
	 			            type: 2,
	 			            fix:true,
	 			            end :function(){
	 			        	    if(isConfirm){
	 			        	    	$("#table_list_1").trigger("reloadGrid");
	 			        	    }
	 			            },
		 			        cancel:function(index){
		 			        	isConfirm = false;
		 			        },
	 			            area: ['80%','80%'],
	 			            content: '<%=contextPath%>/sys/log/updateView?id='+rowData.id
	 			        });    
          			}
          		}
          		</shiro:hasPermission>
          		]
          	);
			</shiro:hasAnyPermission>
		});
	</script>

	<script type="text/javascript">
	$(function() {
		$("#table_list_2").jqGrid({
			url: '<%=contextPath%>/sys/log/listExceptionData',
			data : {},
			datatype : "json",
			autowidth : true,
			shrinkToFit : true,
			mtype : "post",
			rowNum : 20,
			rowList : [ 10, 20, 30 ],
			colNames : ["id", "描述","操作人","操作时间","异常代码","请求IP"],
			colModel : [{
				name : "id",
				index : "id",
				hidden:true
			},  {
				name : "description",
				index : "description",
				width : 50
			},  {
				name : "operatorName",
				index : "operator_name",
				width : 50
			},  {
				name : "createDate",
				index : "create_date",
				width : 50
			},  {
				name : "exceptionCode",
				index : "exception_code",
				width : 50
			},  {
				name : "requestIp",
				index : "request_ip",
				width : 50
			}],
			pager : "#pager_list_2",
			viewrecords : true,
			height : $(window).height() - 160,
			hidegrid : false,
			refresh : true,
		}).navGrid('#pager_list_2',{edit:false,add:false,del:false,search:true,refresh:true});
		
		$(window).bind("resize", function() {
			var a = $("#panel-body-1").width()
			var b = $("#panel-body-2").width()
			if(a>0){
				b=a;
			}
			$("#table_list_2").setGridWidth(b);
			$("#table_list_2").setGridHeight($(window).height() - 160);
			$("#table_list_1").setGridWidth(b);
			$("#table_list_1").setGridHeight($(window).height() - 160);
		})
		
		
		
		<shiro:hasAnyPermission name="sys:log:view"> 
		//对表格设置右键菜单
		context.attach('#table_list_2', [
		<shiro:hasPermission name="sys:log:view">  
      		{
      			text: '查看详情',
      			action:function(){
      				var selectedIds = $("#table_list_2").jqGrid("getGridParam", "selrow");
   				    var rowData = $("#table_list_2").jqGrid("getRowData",selectedIds);
   				    var isConfirm = true;
   				    parent.layer.open({
 			        	title:'日志详情',
 			            type: 2,
 			            fix:true,
 			            end :function(){
 			        	    if(isConfirm){
 			        	    	$("#table_list_2").trigger("reloadGrid");
 			        	    }
 			            },
	 			        cancel:function(index){
	 			        	isConfirm = false;
	 			        },
 			            area: ['80%','80%'],
 			            content: '<%=contextPath%>/sys/log/updateView?id='+rowData.id
 			        });    
      			}
      		}
      		</shiro:hasPermission>
      		]
      	);
		</shiro:hasAnyPermission>
		var b = $(".jqGrid_wrapper").width();
		$("#table_list_2").setGridWidth(b);
	});
		
	</script>

</body>
</html>

